import { FC, Fragment,useState } from "react"
import { Outlet } from "react-router-dom"
import * as api from "@/api"
import { Table } from 'antd';
import type { ColumnsType } from 'antd/es/table';
import type { TableRowSelection } from 'antd/es/table/interface';
interface DataType {
  productCode: number;// 编号
  productName: string;// 名称
  allPrice: number;// 总价
  lowPrice: number;// 优惠
  type: any;// 类型
  orderTime: any;// 订单时间
  count: number;// 数量
  state: string;// 状态
  caozuo: any;// 操作
}
const columns: ColumnsType<DataType> = [
  {
    title: '订单编号',
    dataIndex: 'productCode',
  },
  {
    title: '产品名称',
    dataIndex: 'productName',
  },
  {
    title: '总价',
    dataIndex: 'allPrice',
  },
  {
    title: '优惠',
    dataIndex: 'lowPrice',
  },
  {
    title: '类型',
    dataIndex: 'type',
  },
  {
    title: '订单时间',
    dataIndex: 'orderTime',
  },
  {
    title: '数量',
    dataIndex: 'count',
  },
  {
    title: '状态',
    dataIndex: 'state',
  },
  {
    title: '操作',
    dataIndex: 'caozuo',
  },
];
const data: DataType[] = [];
// for (let i = 0; i < 46; i++) {
//   data.push({
//     key: i,
//     name: `Edward King ${i}`,
//     age: 32,
//     address: `London, Park Lane no. ${i}`,
//   });
// }
console.log(api)
let Order: FC = () => {
    const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
    const onSelectChange = (newSelectedRowKeys: React.Key[]) => {
      console.log('selectedRowKeys changed: ', selectedRowKeys);
      setSelectedRowKeys(newSelectedRowKeys);
    };

    const rowSelection: TableRowSelection<DataType> = {
      selectedRowKeys,
      onChange: onSelectChange,
      selections: [
        Table.SELECTION_ALL,
        Table.SELECTION_INVERT,
        Table.SELECTION_NONE,
        {
          key: 'odd',
          text: 'Select Odd Row',
          onSelect: changableRowKeys => {
            let newSelectedRowKeys = [];
            newSelectedRowKeys = changableRowKeys.filter((_, index) => {
              if (index % 2 !== 0) {
                return false;
              }
              return true;
            });
            setSelectedRowKeys(newSelectedRowKeys);
          },
        },
        {
          key: 'even',
          text: 'Select Even Row',
          onSelect: changableRowKeys => {
            let newSelectedRowKeys = [];
            newSelectedRowKeys = changableRowKeys.filter((_, index) => {
              if (index % 2 !== 0) {
                return true;
              }
              return false;
            });
            setSelectedRowKeys(newSelectedRowKeys);
          },
        },
      ],
    };
    return <Table rowSelection={rowSelection} columns={columns} dataSource={data} />;
  }
  <Outlet />

export default Order